package AEF::DependencyGrabber;

use Modern::Perl;
use Moose;
use Log::Log4perl qw( :easy );

require AEF::AEFProcessor;
require AEF::Module;

extends 'AEF::AEFProcessor';

has 'Libraries' => (
	is => 'rw', 
	isa => 'ArrayRef[Str]', 
	default => sub { [] }
);
has 'AppName' => (
	is => 'rw',
	isa => 'Str',
);

around 'RequireDataForType' => sub
{
	my $orig = shift;
	my $self = shift;
	my $type = shift;

	my $logger = get_logger();
	my $require = $self->$orig($type);
	if($require)
	{
		if(!($type == 2 || $type == 4))
		{
			$require = 0;
		}
	}
	return $require;
};

override 'ProcessBlock' => sub 
{
	my $self = shift;
	my ($type, $data_chunk, $ptr) = @_;
	my $logger = get_logger();
	given($type)
	{
		when(2)
		{
			my $appname = $data_chunk;
			$self->AppName($appname);
		}
		when(4)
		{
			my $lib = $data_chunk;
			$logger->debug("Read libary dependency - $lib");
			push @{$self->Libraries}, $lib;
		}
	}
};


1;

no Moose;


